package com.js.purs.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.js.purs.domain.PurAvoidExpert;
import com.js.purs.service.IPurAvoidExpertService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 回避专家列表Controller
 * 
 * @author lzq
 * @date 20240706
 */
@RestController
@RequestMapping("/avoidExpert")
public class PurAvoidExpertController extends BaseController
{
    @Autowired
    private IPurAvoidExpertService purAvoidExpertService;

    /**
     * 查询回避专家列表列表
     */
    @RequiresPermissions("purs:avoidExpert:list")
    @GetMapping("/list")
    public TableDataInfo list(PurAvoidExpert purAvoidExpert)
    {
        startPage();
        List<PurAvoidExpert> list = purAvoidExpertService.selectPurAvoidExpertList(purAvoidExpert);
        return getDataTable(list);
    }

    /**
     * 导出回避专家列表列表
     */
    @RequiresPermissions("purs:avoidExpert:export")
    @Log(title = "回避专家列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurAvoidExpert purAvoidExpert)
    {
        List<PurAvoidExpert> list = purAvoidExpertService.selectPurAvoidExpertList(purAvoidExpert);
        ExcelUtil<PurAvoidExpert> util = new ExcelUtil<PurAvoidExpert>(PurAvoidExpert.class);
        util.exportExcel(response, list, "回避专家列表数据");
    }

    /**
     * 获取回避专家列表详细信息
     */
    @RequiresPermissions("purs:avoidExpert:query")
    @GetMapping(value = "/{expertCode}")
    public AjaxResult getInfo(@PathVariable("expertCode") String expertCode)
    {
        return success(purAvoidExpertService.selectPurAvoidExpertByExpertCode(expertCode));
    }

    /**
     * 新增回避专家列表
     */
    @RequiresPermissions("purs:avoidExpert:add")
    @Log(title = "回避专家列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PurAvoidExpert purAvoidExpert)
    {
        return toAjax(purAvoidExpertService.insertPurAvoidExpert(purAvoidExpert));
    }

    /**
     * 修改回避专家列表
     */
    @RequiresPermissions("purs:avoidExpert:edit")
    @Log(title = "回避专家列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PurAvoidExpert purAvoidExpert)
    {
        return toAjax(purAvoidExpertService.updatePurAvoidExpert(purAvoidExpert));
    }

    /**
     * 删除回避专家列表
     */
    @RequiresPermissions("purs:avoidExpert:remove")
    @Log(title = "回避专家列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{avoidIds}")
    public AjaxResult remove(@PathVariable Long[] avoidIds)
    {
        return toAjax(purAvoidExpertService.deletePurAvoidExpertByAvoidIds(avoidIds));
    }

    @DeleteMapping("/delAvoidExpertByExpertCode/{expertCode}")
    public AjaxResult delAvoidExpertByExpertCode(@PathVariable("expertCode") String expertCode)
    {
        return toAjax(purAvoidExpertService.deletePurAvoidExpertByExpertCode(expertCode));
    }


    @PostMapping("/delAvoidExpertByBindCode")
    public AjaxResult delAvoidExpertByBindCode(@RequestBody List<PurAvoidExpert> purAvoidExpert)
    {
        return toAjax(purAvoidExpertService.deletePurAvoidExpertByBindCode(purAvoidExpert));
    }

}
